package edu.ynu.MyProject.dao;

import edu.ynu.MyProject.common.dao.LogicDAO;
import edu.ynu.MyProject.entity.Equipment;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface IEquipmentDAO extends LogicDAO<Equipment, Long> {
    List<Equipment> findByGreenhouseId(Long greenhouseId);

    @Query("SELECT e.id FROM Equipment e WHERE e.type='detector' AND  e.greenhouse.id = :greenhouseId")
    List<Long> getDeviceIdsByGreenhouseId(Long greenhouseId);

    @Query("SELECT e.serial FROM Equipment e WHERE e.greenhouse.id = :greenhouseId AND e.type = 'camera'")
    String findSerialByGreenhouseIdAndType(Long greenhouseId);
}
